const Sequelize = require('sequelize');
module.exports = function(sequelize, DataTypes) {
  return sequelize.define('act_de_model_relation', {
    id: {
      type: DataTypes.STRING(255),
      allowNull: false,
      primaryKey: true
    },
    parentModelId: {
      type: DataTypes.STRING(255),
      allowNull: true,
      references: {
        model: 'act_de_model',
        key: 'id'
      },
      field: 'parent_model_id'
    },
    modelId: {
      type: DataTypes.STRING(255),
      allowNull: true,
      references: {
        model: 'act_de_model',
        key: 'id'
      },
      field: 'model_id'
    },
    relationType: {
      type: DataTypes.STRING(255),
      allowNull: true,
      field: 'relation_type'
    }
  }, {
    sequelize,
    tableName: 'act_de_model_relation',
    timestamps: false,
    indexes: [
      {
        name: "PRIMARY",
        unique: true,
        using: "BTREE",
        fields: [
          { name: "id" },
        ]
      },
      {
        name: "fk_relation_parent",
        using: "BTREE",
        fields: [
          { name: "parent_model_id" },
        ]
      },
      {
        name: "fk_relation_child",
        using: "BTREE",
        fields: [
          { name: "model_id" },
        ]
      },
    ]
  });
};
